local skel = fk.CreateSkill {
  name = "efengqi__huibian",
  tags = {Skill.Lord, Skill.Limited},
}

Fk:loadTranslationTable{
  ["efengqi__huibian"] = "挥鞭",

  [":efengqi__huibian"] = "主公技，限定技，出牌阶段，你可以将牌堆顶的牌当【杀】对两名角色使用，若含魏势力，你的下个回合开始时，此技能视为未发动。",
  ["#efengqi__huibian"] = "挥鞭:将牌堆顶两张牌当【杀】对两名角色使用，若含魏势力，下回合重置",

  ["$efengqi__huibian1"] = "吾任天下之智力，以道御之，无所不可。",
  ["$efengqi__huibian2"] = "青青子衿，悠悠我心，但为君故，沉吟至今。",
}

skel:addEffect("active", {
  anim_type = "offensive",
  card_num = 0,
  min_target_num = 1,
  prompt = "#efengqi__huibian",
  card_filter = Util.FalseFunc,
  target_filter = function (self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected < 2 and not player:isProhibited(to_select, Fk:cloneCard("slash"))
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryGame) == 0
    and not player:prohibitUse(Fk:cloneCard("slash"))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local card = Fk:cloneCard("slash")
    card.skillName = skel.name
    card:addSubcards(room:getNCards(2))
    room:useCard{
      from = player,
      tos = effect.tos,
      card = card,
      extraUse = true,
    }
    if table.find(effect.tos, function(to) return to.kingdom == "wei" end) then
      room:setPlayerMark(player, "efengqi__huibian_mark", 1)
    end
  end,
})

skel:addEffect(fk.TurnStart, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:getMark("efengqi__huibian_mark") ~= 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "efengqi__huibian_mark", 0)
    player:setSkillUseHistory(skel.name, 0, Player.HistoryGame)
  end,
})

return skel
